<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/5/15
 * Time: 16:37
 */

namespace app\admin\validate;


use think\Validate;

class Goods extends Validate
{

    protected $rule = [
        'good_name'  =>'require|unique:GoodsList',
        'driver_id'  =>'require',
        'price'  =>'require',
        'old_price'  =>'require',
        '__token__' => 'require|token'
    ];

    protected $message = [
        'good_name.require' => '商品名称必填',
        'good_name.unique' => '商品名称已存在',
        'driver_id.require' => '驾照类型必选',
        'price.require' => '价格必填',
        'old_price.require' => '原价价必填',
        '__token__.token'    => '你已经提交过了',
    ];

    protected $scene = [
        'add'=>['good_name','driver_id','price','old_price','__token__']
    ];
    public function sceneEdit(){
        return $this->only(['good_name'])
            ->remove('good_name', 'unique');
    }

}